const express = require("express");
const app = express();
const cors = require("cors");
const session = require("express-session");
const api = require("./router");

app.use(express.json());
app.use(express.urlencoded({ extended: true }));

app.use(
    cors({
        origin: "*",
        credentials: true,
    })
);

app.use(
    session({
        secret: "secret",
        resave: true,
        saveUninitialized: true,
        cookie: {
            maxAge: 1000 * 60 * 60 * 2, // 2小时
        },
    })
);

app.use("/api", api);

app.listen(3000, function () {
    console.log("Server started on port 3000");
});
